<?php

namespace app\controller\backed;

use app\BaseController;
use app\model\Photo as PhotoModel;
use app\model\DingUser as DingUserModel;

class Photo extends BaseController
{

    public function getPhotos()
    {
        $params = request()->param();

        $pageNo = isset($params['pageNo']) ? $params['pageNo'] : 1;
        $pageSize = isset($params['pageSize']) ? $params['pageSize'] : 20;

        $res = PhotoModel::where('user_id = '.$params['uid'])->paginate(
            $pageSize, false, [
            'page' => $pageNo
        ]);

        return $this->successMessage('查询成功',$res);
    }

    public function createPhoto()
    {       

        $params = request()->param();
        $uid = $params['uid'];

        $data = [
        	'photo' => $params['photo'],
            'user_id' => $uid
        ];

        $photoModel = new PhotoModel();
        $photoModel->save($data);

        return $this->successMessage('创建成功');

    }


    public function deletePhoto()
    {

        $params = request()->param();
        PhotoModel::destroy($params['id']);
        
        return $this->successMessage('删除成功');
    }


}